package net.jumpengine.po;

import net.jumpengine.enume.TextAlign;

/**
 * 用于表格显示的列,如TableBase.默认宽度按列数均分,向左对齐,空列名.<br />
 * width值为-1时,表示按照列数平分表格宽度,并无视其他列宽度设置;<br />
 * 为0时,为表格剩余宽度;为1-表格宽度时,为固定宽度.<br />
 * 超出表格宽度时,视为0.
 * <br /><br />
 * <b>作者:&nbsp;</b>张天文 <br />
 * <b>日期:&nbsp;</b>2020年3月25日 上午10:43:54<br />
 * @date
 */
public class Column {
	/** 列名 */
	private String name="";
	/** 键名,当数据以List&lt;Map&gt;形式提供 */
	private String key="";
	private TextAlign textAlign=TextAlign.left;
	private int width=-1;
	/** 日期格式化字符串,如果Column有,则采用此处的,没有则采用ITable的  */
	private String dateFormat;
	/** 数字格式化字符串,如果Column有,则采用此处的,没有则采用ITable的  */
	private String doubleFormat;
	private String intFormat;
	/** 逻辑值格式化值,长度2,第一个为是,没有则采用ITable的 */
	private String[] booleanFormat;
	private boolean no=false;
	private int mathWidth;
	private int left;

	public Column(String name) {
		this.name = name;
	}
	
	/**
	 * 当数据以List&lt;Map&gt;形式提供,建议用此构造方法
	 * @param name 列名
	 * @param key 键名,当数据以List&lt;Map&gt;形式提供,会以key从map获得数据
	 * @param table TableBase或其子类
	 */
	public Column(String name,String key) {
		this.name = name;
		this.key=key;
	}
	
	public Column(String name,String key,int width) {
		this.name = name;
		this.key=key;
		this.width = width;
	}
	
	public Column(String name,boolean no) {
		this.name = name;
		this.no=no;
	}
	
	public Column(String name,int width) {
		this.name = name;
		this.width = width;
	}
	
	public Column(String name, TextAlign textAlign) {
		this.name = name;
		this.textAlign = textAlign;
	}

	public Column(String name, TextAlign textAlign, int width) {
		this.name = name;
		this.textAlign = textAlign;
		this.width = width;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public TextAlign getTextAlign() {
		return textAlign;
	}

	public void setTextAlign(TextAlign textAlign) {
		this.textAlign = textAlign;
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public String getDateFormat() {
		return dateFormat;
	}

	public void setDateFormat(String dateFormat) {
		this.dateFormat = dateFormat;
	}

	public boolean isNo() {
		return no;
	}

	public void setNo(boolean no) {
		this.no = no;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public int getMathWidth() {
		return mathWidth;
	}

	public void setMathWidth(int mathWidth) {
		this.mathWidth = mathWidth;
	}

	public String[] getBooleanFormat() {
		return booleanFormat;
	}

	public void setBooleanFormat(String[] booleanFormat) {
		this.booleanFormat = booleanFormat;
	}

	@Override
	public String toString() {
		return "Column [name=" + name + ", key=" + key + ", textAlign=" + textAlign + ", width=" + width + ", no=" + no
				+ ", mathWidth=" + mathWidth + "]";
	}

	public int getLeft() {
		return left;
	}

	public void setLeft(int left) {
		this.left = left;
	}

	public String getDoubleFormat() {
		return doubleFormat;
	}

	public void setDoubleFormat(String doubleFormat) {
		this.doubleFormat = doubleFormat;
	}

	public String getIntFormat() {
		return intFormat;
	}

	public void setIntFormat(String intFormat) {
		this.intFormat = intFormat;
	}
}
